﻿#ifndef QEXCELDOCUMENT_H
#define QEXCELDOCUMENT_H

#include <QObject>
#include <QAxObject>
#include "qexcelsheet.h"

class QExcelSheet;

class QExcelDocument : public QObject
{
    Q_OBJECT

public:
    explicit QExcelDocument(QString filePath,QObject *parent = nullptr);
    ~QExcelDocument();

    bool isAvailable();
    QString filePath();

    int sheetCount();
    QStringList sheetNames();
    QExcelSheet* activeSheet();
    bool setActiveSheet(int sheetIndex);
    bool setActiveSheet(QString sheetName);
    bool addSheet(QString sheetName);
    bool deleteSheet(int sheetIndex);
    bool deleteSheet(QString sheetName);
    bool deleteAllSheet();

    bool save();
    bool saveAs(QString filePath);



//    bool renameSheet(const QString &oldSheetName, const QString &newSheetName);



//    bool write(const CellReference &cell, const QVariant &value, const Format &format = Format());
//    bool write(int row, int col, const QVariant &value, const Format &format = Format());
//    bool writeRange(const CellRange &range,const QVariantList &valueList, const Format &format = Format());
//    QVariant read(const CellReference &cell) const;
//    QVariant read(int row, int col) const;
//    QVariantList readRange(const CellRange &range);
//    bool insertImage(int row, int col, const QImage &image);
//    Chart *insertChart(int row, int col, const QSize &size);
//    bool mergeCells(const CellRange &range, const Format &format = Format());
//    bool unmergeCells(const CellRange &range);

//    bool setColumnWidth(const CellRange &range, double width);
//    bool setColumnFormat(const CellRange &range, const Format &format);
//    bool setColumnHidden(const CellRange &range, bool hidden);
//    bool setColumnWidth(int column, double width);
//    bool setColumnFormat(int column, const Format &format);
//    bool setColumnHidden(int column, bool hidden);
//    bool setColumnWidth(int colFirst, int colLast, double width);
//    bool setColumnFormat(int colFirst, int colLast, const Format &format);
//    bool setColumnHidden(int colFirst, int colLast, bool hidden);
//    double columnWidth(int column);
//    Format columnFormat(int column);
//    bool isColumnHidden(int column);

//    bool setRowHeight(int row, double height);
//    bool setRowFormat(int row, const Format &format);
//    bool setRowHidden(int row, bool hidden);
//    bool setRowHeight(int rowFirst, int rowLast, double height);
//    bool setRowFormat(int rowFirst, int rowLast, const Format &format);
//    bool setRowHidden(int rowFirst, int rowLast, bool hidden);

//    double rowHeight(int row);
//    Format rowFormat(int row);
//    bool isRowHidden(int row);

//    bool groupRows(int rowFirst, int rowLast, bool collapsed = true);
//    bool groupColumns(int colFirst, int colLast, bool collapsed = true);
//    bool addDataValidation(const DataValidation &validation);
//    bool addConditionalFormatting(const ConditionalFormatting &cf);

//    Cell *cellAt(const CellReference &cell) const;
//    Cell *cellAt(int row, int col) const;

//    bool defineName(const QString &name, const QString &formula, const QString &comment = QString(),
//                    const QString &scope = QString());

//    CellRange dimension() const;

//    QString documentProperty(const QString &name) const;
//    void setDocumentProperty(const QString &name, const QString &property);
//    QStringList documentPropertyNames() const;

//    QStringList sheetNames() const;
//    bool addSheet(const QString &name = QString(),
//                  AbstractSheet::SheetType type = AbstractSheet::ST_WorkSheet);
//    bool insertSheet(int index, const QString &name = QString(),
//                     AbstractSheet::SheetType type = AbstractSheet::ST_WorkSheet);
//    bool selectSheet(const QString &name);
//    bool renameSheet(const QString &oldName, const QString &newName);
//    bool copySheet(const QString &srcName, const QString &distName = QString());
//    bool moveSheet(const QString &srcName, int distIndex);
//    bool deleteSheet(const QString &name);

//    Workbook *workbook() const;
//    AbstractSheet *sheet(const QString &sheetName) const;
//    AbstractSheet *currentSheet() const;
//    Worksheet *currentWorksheet() const;

//    bool save() const;
//    bool saveAs(const QString &xlsXname) const;


private:
    QAxObject *m_excelWorkbook;

    QString m_filePath;
    bool m_isAvailable;
};

#endif // QEXCELDOCUMENT_H
